home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume23 / sc6.8 / part01 next >
Encoding:
Internet Message Format  |  1990-10-09  |  52.7 KB

  1. Subject:  v23i021:  The SC Spreadsheet, release 6.8, Part01/06
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 734e5634 f01da32e 5cdd0a22 2f00bb17
  5.  
  6. Submitted-by: Jeff Buhrt <sawmill!buhrt>
  7. Posting-number: Volume 23, Issue 21
  8. Archive-name: sc6.8/part01
  9.  
  10. This is a much modified version of the public domain spread sheet sc,
  11. posted several years ago by Mark Weiser as vc, originally by James
  12. Gosling.
  13.  
  14. Starting 4/4/90: (I will be maintaining Sc for a while at least, Robert
  15. Bond has been very busy lately) Sc is not a product of Grauel Enterprises,
  16. Inc.  It is supplied as is with no warranty, express or implied, as a
  17. service to Usenet readers.  It is not copyrighted, either.  Have at it.
  18.                     Jeff Buhrt
  19.                     Grauel Enterprises, Inc.
  20.     {pur-phy (aka: newton.physics.purdue.edu), sequent}!sawmill!buhrt
  21.  
  22. #! /bin/sh
  23. # This is a shell archive.  Remove anything before this line, then feed it
  24. # into a shell via "sh file" or similar.  To overwrite existing files,
  25. # type "sh file -c".
  26. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  27. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  28. # Contents:  README MANIFEST sc.doc
  29. # Wrapped by rsalz@litchi.bbn.com on Fri Jul 13 15:24:17 1990
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. echo If this archive is complete, you will see the following message:
  32. echo '          "shar: End of archive 1 (of 6)."'
  33. if test -f 'README' -a "${1}" != "-c" ; then 
  34.   echo shar: Will not clobber existing file \"'README'\"
  35. else
  36.   echo shar: Extracting \"'README'\" \(3004 characters\)
  37.   sed "s/^X//" >'README' <<'END_OF_FILE'
  38. XThis is a much modified version of the public domain spread sheet sc,
  39. Xposted several years ago by Mark Weiser as vc, originally by James Gosling.
  40. X
  41. XChanges since my last version (5.1) are detailed at great length :-)
  42. Xin CHANGES (sequent!rgb (Robert Bond)).
  43. X
  44. XWhen you get it built, try "sc tutorial.sc" for a simple introduction
  45. Xto the basic commands.
  46. X
  47. XA new input parser program (psc) has been included.  This program
  48. Xformats ascii files for use in the spread sheet.  If you don't have
  49. Xgetopts, there is a public domain version by Henry Spencer hidden away
  50. Xin the VMS_NOTES file.
  51. X
  52. XI have modified the makefile to make it easy for you to call the
  53. Xprogram what you want (I saw at least five different names in
  54. Xcorrespondence and on the net).  Just change "name=sc" and "NAME=SC" to
  55. X"name=myfavoritename" and "NAME=MYFAVORITENAME" and try "make
  56. Xmyfavoritename".
  57. X
  58. XSimilarly, you can make the documentation with "make myfavoritename.man".
  59. X"make install" will make and install the code in EXDIR.  The
  60. Xinstallation steps and documentation all key off of the name.  The
  61. Xmakefile even changes the name in the nroffable man page.  If you don't
  62. Xhave nroff, you will have to change sc.man yourself.
  63. X
  64. XThis release has been tested against a Sequent S81 running DYNIX 3.0.14
  65. X(BSD 4.2) and an ICM-3216 with system V.3.  The ICM has a National Semi
  66. X32016.  Just check the makefile for the system flags.   I have heard
  67. Xreports of lots of other machines that work. If you have problems with
  68. Xlex.c, and don't care about arrow keys, define SIMPLE (-DSIMPLE in the
  69. Xmakefile).  SIMPLE causes the arrow keys to not be used.
  70. X
  71. XGuidelines for Hackers:
  72. X
  73. XIf you want to send changes you have made to SC, please feel free to do
  74. Xso.  If they work :-) and seem worthwhile, I'll put them in.  Please
  75. Xrefrain from wholesale "style" or "cleanup" changes.  It is easy to add
  76. Xyour changes but it makes it hard to merge in the next guy's stuff if
  77. Xhe used the release as a base.  Leave my $Revision:  identifiers alone-
  78. Xthey help me track what you used as a base.  If you check the code into
  79. Xrcs, delete the "$"s on the Revison lines before you do.
  80. X
  81. XYou may not like 4 space indenting and curly braces on the "if" line,
  82. Xbut your code will look like that before it leaves my hands so you may
  83. Xas well abide by the style in the code when you make your changes.  I
  84. Xhave also been known to break things trying to make them look "right".
  85. XIf you do string functions, please, PLEASE pay attention to null
  86. Xpointers, use xmalloc and xfree, and xfree those arguments.  And
  87. Xdon't forget to document your changes in both help.c and sc.doc.
  88. X
  89. XDisclaimer:
  90. X
  91. XStarting 4/4/90: (I will be maintaining Sc for a while at least,
  92. X    Robert Bond has been very busy lately)
  93. XSc is not a product of Grauel Enterprises, Inc.  It is supplied as
  94. Xis with no warranty, express or implied, as a service to Usenet readers.
  95. XIt is not copyrighted, either.  Have at it.
  96. X
  97. X                    Jeff Buhrt
  98. X                    Grauel Enterprises, Inc.
  99. X    {pur-phy (aka: newton.physics.purdue.edu), sequent}!sawmill!buhrt
  100. END_OF_FILE
  101.   if test 3004 -ne `wc -c <'README'`; then
  102.     echo shar: \"'README'\" unpacked with wrong size!
  103.   fi
  104.   # end of 'README'
  105. fi
  106. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  107.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  108. else
  109.   echo shar: Extracting \"'MANIFEST'\" \(983 characters\)
  110.   sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  111. X   File Name        Archive #    Description
  112. X----------------------------------------------------------
  113. XREADME                     1    
  114. XMANIFEST                   1    This shipping list
  115. XCHANGES                    5    
  116. XMakefile                   6    
  117. XTODO                       6    
  118. XVMS_NOTES                  6    
  119. Xcmds.c                     4    
  120. Xcrypt.c                    6    
  121. Xeres.sed                   5    
  122. Xgram.y                     5    
  123. Xhelp.c                     3    
  124. Xinterp.c                   2    
  125. Xlex.c                      4    
  126. Xpsc.c                      4    
  127. Xpsc.doc                    5    
  128. Xrange.c                    5    
  129. Xsc.c                       3    
  130. Xsc.doc                     1    
  131. Xsc.h                       5    
  132. Xsc6.8p1.hdr                2    
  133. Xsc6.8p2.hdr                6    
  134. Xsc6.8p3.hdr                6    
  135. Xsc6.8p4.hdr                6    
  136. Xsres.sed                   2    
  137. Xtutorial.sc                6    
  138. Xversion.c                  5    
  139. Xvi.c                       5    
  140. Xvmtbl.c                    5    
  141. Xxmalloc.c                  4    
  142. END_OF_FILE
  143.   if test 983 -ne `wc -c <'MANIFEST'`; then
  144.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  145.   fi
  146.   # end of 'MANIFEST'
  147. fi
  148. if test -f 'sc.doc' -a "${1}" != "-c" ; then 
  149.   echo shar: Will not clobber existing file \"'sc.doc'\"
  150. else
  151.   echo shar: Extracting \"'sc.doc'\" \(45229 characters\)
  152.   sed "s/^X//" >'sc.doc' <<'END_OF_FILE'
  153. X.\" Warning:  The string "pname" is converted to the true program name
  154. X.\" by the makefile, throughout this document.
  155. X.\"
  156. X.\" Warning:  The order of presentation of commands largely matches the
  157. X.\" help screen built into the program.
  158. X.\"
  159. X.\" Conventions:
  160. X.\" - pname italicized and never uppercased (it's a proper name).
  161. X.\" - Refer to lists of commands in the same order as introduced.
  162. X.\" - Command and function names bold when introduced, italicized in all
  163. X.\"   other places if possible, or in `` '' if not.
  164. X.\" - Cell names italicized except when used in expressions; row numbers
  165. X.\"   and column names not italicized.
  166. X.\" - Use `` '' rather than " " except referring to literal input or output.
  167. X.\" - TPs use default indent except for function names, then 18.
  168. X.\" - Smallify uppercase strings.
  169. X.\" - Avoid passive voice and third person.
  170. X.\" $Revision: 6.8 $
  171. X.\"
  172. X.TH PNAME 1
  173. X.SH NAME
  174. Xpname \- spreadsheet calculator
  175. X.SH SYNOPSIS
  176. X.B pname
  177. X[
  178. X.B -c
  179. X]
  180. X[
  181. X.B -m
  182. X]
  183. X[
  184. X.B -n
  185. X]
  186. X[
  187. X.B -r
  188. X]
  189. X[
  190. X.B -x
  191. X]
  192. X[
  193. X.I file
  194. X]
  195. X.\" ==========
  196. X.SH DESCRIPTION
  197. XThe spreadsheet calculator
  198. X.I pname
  199. Xis based on rectangular tables much like a financial spreadsheet.
  200. XWhen invoked it presents you with a table
  201. Xorganized as rows and columns of cells.
  202. XIf invoked without a
  203. X.I file
  204. Xargument, the table is initially empty.
  205. XOtherwise
  206. X.I file
  207. Xis read in (see the
  208. X.I Get
  209. Xcommand below).
  210. XEach cell may have associated with it
  211. Xa numeric value,
  212. Xa label string,
  213. Xand/or an expression (formula)
  214. Xwhich evaluates to a numeric value or label string,
  215. Xoften based on other cell values.
  216. X.\" ----------
  217. X.PP
  218. XOptions are:
  219. X.\" ----------
  220. X.TP
  221. X.B \-c
  222. XStart the program with the recalculation being done in column order.
  223. X.\" ----------
  224. X.TP
  225. X.B \-m
  226. XStart the program with automatic recalculation disabled.
  227. XThe spreadsheet will be recalculated only when the ``@'' command is used.
  228. X.\" ----------
  229. X.TP
  230. X.B \-n
  231. XStart the program in quick numeric entry mode (see below).
  232. X.\" ----------
  233. X.TP
  234. X.B \-r
  235. XStart the program with the recalculation being done in row
  236. Xorder (default option).
  237. X.\" ----------
  238. X.TP
  239. X.B \-x
  240. XCause the
  241. X.I Get
  242. Xand
  243. X.I Put
  244. Xcommands (see below) to encrypt and decrypt data files.
  245. X.\" ----------
  246. X.PP
  247. XAll of these options can be changed with the
  248. X.I ^T
  249. Xand 
  250. X.I S
  251. Xcommands (see below) while
  252. X.I pname
  253. Xis running.  Options specified when
  254. X.I pname 
  255. Xis invoked
  256. Xoverride options saved in the data file.
  257. X.\" ==========
  258. X.SS "General Information"
  259. X.\" ----------
  260. XThe screen is divided into four regions.
  261. XThe top line is for entering commands and displaying cell values.
  262. XThe second line is for messages from
  263. X.IR pname .
  264. XThe third line and the first four columns show the column and row numbers,
  265. Xfrom which are derived cell addresses, e.g.
  266. X.I A0
  267. Xfor the cell in column A, row 0.
  268. XNote that column names are case-insensitive: you can enter
  269. X.I A0
  270. Xor
  271. X.IR a0 .
  272. X.\" ----------
  273. X.PP
  274. XThe rest of the screen forms a window looking at a portion of the table.
  275. XThe total number of display rows and columns available,
  276. Xhence the number of table rows and columns displayed,
  277. Xis set by
  278. X.IR curses (3)
  279. Xand may be overridden by setting the
  280. X.SM LINES
  281. Xand
  282. X.SM COLUMNS
  283. Xenvironment variables, respectively.
  284. X.\" ----------
  285. X.PP
  286. XThe screen has two cursors:
  287. Xa cell cursor, indicated by a highlighted cell and a ``<'' on the screen,
  288. Xand a character cursor, indicated by the terminal's hardware cursor.
  289. XThe cell and character cursors are often the same.
  290. XThey differ when you type a command on the top line.
  291. X.\" ----------
  292. X.PP
  293. XIf a cell's numeric value is wider than the column width (see the
  294. X.I f
  295. Xcommand), the cell is filled with asterisks.
  296. XIf a cell's label string is wider than the column width,
  297. Xit is truncated at the start of the next non-blank cell in the row, if any.
  298. X.\" ----------
  299. X.PP
  300. XCursor control commands and row and column commands
  301. Xcan be prefixed by a numeric argument
  302. Xwhich indicates how many times the command is to be executed.
  303. XYou can type
  304. X.I ^U
  305. Xbefore a repeat count if quick numeric entry mode is enabled
  306. Xor if the number is to be entered
  307. Xwhile the character cursor is on the top line.
  308. X.\" ----------
  309. X.PP
  310. XCommands which use the terminal's control key, such as
  311. X.IR ^N ,
  312. Xwork both when a command is being typed and when in normal mode.
  313. X.\" ==========
  314. X.SS "Changing Options"
  315. X.\" ----------
  316. X\0 \" exactly one blank line (hard to get)
  317. X.PD 0
  318. X.TP
  319. X.BI ^T o
  320. XToggle options.
  321. XThis command allows you to switch the state of one option selected by
  322. X.IR o .
  323. XA small menu lists the choices for
  324. X.I o
  325. Xwhen you type
  326. X.IR ^T .
  327. XThe options selected are saved when the data and formulas are saved
  328. Xso that you will have the same setup next time you enter the
  329. Xspreadsheet. 
  330. X.PD
  331. X.RS
  332. X.\" ----------
  333. X.TP
  334. X.B a
  335. XAutomatic Recalculation.
  336. XWhen set, each change in the spreadsheet causes the entire spreadsheet
  337. Xbe recalculated.  Normally this is not noticeable, but for very large
  338. Xspreadsheets, it may be faster to clear automatic recalculation mode and
  339. Xupdate the spreadsheet via explicit ``@'' commands.  Default is 
  340. Xautomatic recalculation on.
  341. X.\" ----------
  342. X.TP
  343. X.B c
  344. XCurrent cell highlighting.
  345. XIf enabled, the current cell is highlighted
  346. X(using the terminal's standout mode, if available)
  347. Xin addition to being marked by the cell cursor.
  348. X.\" ----------
  349. X.TP
  350. X.B e
  351. XExternal function execution.
  352. XWhen disabled, external functions (see
  353. X.IR @ext ()
  354. Xbelow) are not called.
  355. XThis saves a lot of time at each screen update.
  356. XExternal functions are disabled by default.
  357. XIf disabled, and external functions are used anywhere,
  358. Xa warning is printed each time the screen is updated,
  359. Xand the result of
  360. X.IR @ext ()
  361. Xis the value from the previous call, if any, or a null string.
  362. X.\" ----------
  363. X.TP
  364. X.B n
  365. XQuick numeric entry.
  366. XIf enabled,
  367. Xa typed digit is assumed to be
  368. Xthe start of a numeric value for the current cell,
  369. Xnot a repeat count, unless preceded by
  370. X.IR ^U .
  371. X.\" ----------
  372. X.TP
  373. X.B t
  374. XTop line display.
  375. XIf enabled,
  376. Xthe name and value of the current cell is displayed on the top line.
  377. XIf there is an associated label string,
  378. Xthe first character of the string value
  379. Xis ``<'' for a leftstring or ``>'' for a rightstring (see below),
  380. Xfollowed by "\fIstring\fP" for a constant string
  381. Xor
  382. X.RI { expr }
  383. Xfor a string expression.
  384. XIf the cell has a numeric value,
  385. Xit follows as
  386. X.RI [ value ],
  387. Xwhich may be a constant or expression.
  388. X.\" ----------
  389. X.TP
  390. X.B x
  391. XEncryption.
  392. XSee the
  393. X.B \-x
  394. Xoption.
  395. X.\" ----------
  396. X.TP
  397. X.B $
  398. XDollar prescale.
  399. XIf enabled, all numeric
  400. X.B constants
  401. X(not expressions) which you enter are multipled by 0.01
  402. Xso you don't have to keep typing the decimal point
  403. Xif you enter lots of dollar figures.
  404. X.RE
  405. X.\" ----------
  406. X\0 \" exactly one blank line (hard to get)
  407. X.PD 0
  408. X.TP
  409. X.B S
  410. XSet options.  This command allows you to set various options.
  411. XA small menu lists the options that cannot be changed through
  412. X.I ^T
  413. Xabove.
  414. X.PD
  415. X.RS
  416. X.TP
  417. X.BR byrows /  bycols
  418. XSpecify the order cell evaluation when updating.  These options also affect
  419. Xthe order in which cells are filled (see 
  420. X.IR /f )
  421. Xand whether a row or column is cleared by an 
  422. X.I x
  423. Xcommand.
  424. X.TP
  425. X.BI iterations =n
  426. XSet the maximum number of recalculations before
  427. Xthe screen is displayed again. 
  428. X.I Iterations
  429. Xis set to 10 by default.
  430. X.TP
  431. X.BI tblstyle =s
  432. XControl the output of the 
  433. X.I T
  434. Xcommand.
  435. X.I s
  436. Xcan be:
  437. X.B 0
  438. X(default) to give colon delimited fields, with no 
  439. X.I tbl
  440. Xcontrol lines;
  441. X.B tbl
  442. Xto give colon delimited fields, with
  443. X.IR tbl (1)
  444. Xcontrol lines;
  445. X.B latex
  446. Xto give a
  447. X.I LaTeX
  448. Xtabular environment; and
  449. X.B tex
  450. Xto give a
  451. X.I TeX
  452. Xsimple tabbed alignment with ampersands as delimiters.
  453. X.PP
  454. XOther
  455. X.I Set
  456. Xoptions are normally used only in 
  457. X.I pname
  458. Xdata files since they are available through 
  459. X.IR ^T .
  460. XYou can also use them interactively
  461. X.TP
  462. X.BR autocalc / !autocalc
  463. XSet/clear auto recalculation mode.
  464. X.TP
  465. X.BR numeric / !numeric
  466. XSet/clear numeric mode.
  467. X.TP
  468. X.BR prescale / !prescale
  469. XSet/clear numeric prescale mode.
  470. X.TP
  471. X.BR extfun / !extfun
  472. XEnable/disable external functions.
  473. X.TP
  474. X.BR cellcur / !cellcur
  475. XSet/clear current cell highlighting mode.
  476. X.TP
  477. X.BR toprow /  !toprow
  478. XSet/clear top row display mode.
  479. X.RE
  480. X.\" ==========
  481. X.SS "Cursor Control Commands"
  482. X.\" ----------
  483. X\0 \" exactly one blank line (hard to get)
  484. X.PD 0
  485. X.TP
  486. X.B ^P
  487. XMove the cell cursor up to the previous row.
  488. X.PD
  489. X.\" ----------
  490. X.TP
  491. X.B ^N
  492. XMove the cell cursor down to the next row.
  493. X.\" ----------
  494. X.TP
  495. X.B ^B
  496. XMove the cell cursor backward one column.
  497. X.\" ----------
  498. X.TP
  499. X.B ^F
  500. XMove the cell cursor forward one column.
  501. X.\" ----------
  502. X.TP
  503. X.B "h, j, k, l"
  504. XIf the character cursor is not on the top line, these are alternate,
  505. X.IR vi -compatible
  506. Xcell cursor controls (left, down, up, right).
  507. X.\" ----------
  508. X.TP
  509. X.B ^H
  510. XIf the character cursor is not on the top line,
  511. X.I ^H
  512. Xis the same as
  513. X.IR ^B .
  514. X.\" ----------
  515. X.TP
  516. X.B SPACE
  517. XIf the character cursor is not on the top line,
  518. Xthe space bar is the same as
  519. X.IR ^F .
  520. X.\" ----------
  521. X.TP
  522. X.B TAB
  523. XIf the character cursor is on the top line,
  524. X.SM TAB
  525. Xstarts a range (see below).
  526. XOtherwise, it is the same as
  527. X.IR ^F .
  528. X.\" ----------
  529. X.TP
  530. X.B "Arrow Keys"
  531. XThe terminal's arrow keys provide another alternate set of cell cursor controls
  532. Xif they exist and are supported in the appropriate
  533. X.I termcap
  534. Xentry.
  535. XSome terminals have arrow keys which conflict with other control key codes.
  536. XFor example, a terminal might send
  537. X.I ^H
  538. Xwhen the back arrow key is pressed.
  539. XIn these cases, the conflicting arrow key performs the same function
  540. Xas the key combination it mimics.
  541. X.\" ----------
  542. X.TP
  543. X.B ^
  544. XMove the cell cursor up to row 0 of the current column.
  545. X.\" ----------
  546. X.TP
  547. X.B #
  548. XMove the cell cursor down to the last valid row of the current column.
  549. X.\" ----------
  550. X.TP
  551. X.B 0
  552. XMove the cell cursor backward to column A of the current row.
  553. XThis command must be prefixed with
  554. X.I ^U
  555. Xif quick numeric entry mode is enabled.
  556. X.\" ----------
  557. X.TP
  558. X.B $
  559. XMove the cell cursor forward to the last valid column of the current row.
  560. X.\" ----------
  561. X.TP
  562. X.B b
  563. XScan the cursor backward (left and up) to the previous valid cell.
  564. X.\" ----------
  565. X.TP
  566. X.B w
  567. XScan the cursor forward (right and down) to the next valid cell.
  568. X.\" ----------
  569. X.TP
  570. X.BI ^E d
  571. XGo to end of range.
  572. XFollow
  573. X.I ^E
  574. Xby a direction indicator such as
  575. X.I ^P
  576. Xor
  577. X.IR j .
  578. XIf the cell cursor starts on a non-blank cell,
  579. Xit goes in the indicated direction until the last non-blank adjacent cell.
  580. XIf the cell cursor starts on a blank cell,
  581. Xit goes in the indicated direction until the first non-blank cell.
  582. XThis command is useful when specifying ranges of adjacent cells (see below),
  583. Xespecially when the range is bigger than the visible window.
  584. X.\" ----------
  585. X.TP
  586. X.B g
  587. XGo to a cell.
  588. X.I pname
  589. Xprompts for a cell's name, a regular expression surrounded by
  590. Xquotes, or a number.
  591. XIf a cell's name such as
  592. X.I ae122 
  593. Xor a the name of a defined range is given, the cell cursor goes
  594. Xdirectly to that cell.
  595. XIf a quoted regular expression such as "
  596. X.I Tax Table 
  597. X" or "
  598. X.I ^Jan [0-9]*$
  599. X" is given,
  600. X.I pname
  601. Xsearches for a cell containing a string matching the regular
  602. Xexpression.
  603. XSee 
  604. X.I regex(3)
  605. Xor
  606. X.I ed(1)
  607. Xfor more details on the form of regular
  608. Xexpressions.
  609. XIf a number is given, 
  610. X.I pname
  611. Xwill search for a cell containing that number.
  612. XSearches for either strings or numbers proceed forward from the
  613. Xcurrent cell, wrapping back to a0 at the end of the table, and
  614. Xterminate at the current cell if the string or number is not found.
  615. XThe last
  616. X.I g
  617. Xcommand is saved, and can be re-issued by entering 
  618. X.IR g<return> .
  619. X.\" ==========
  620. X.SS "Cell Entry and Editing Commands"
  621. X.\" ----------
  622. XCells can contain both a numeric value and a string value.
  623. XEither value can be the result of an expression,
  624. Xbut not both at once,
  625. Xi.e. each cell can have only one expression associated with it.
  626. XEntering a valid numeric expression
  627. Xalters the cell's previous numeric value, if any,
  628. Xand replaces the cell's previous string expression, if any,
  629. Xleaving only the previously computed constant label string.
  630. XLikewise, entering a valid string expression
  631. Xalters the cell's the previous label string, if any,
  632. Xand replaces the cell's previous numeric expression, if any,
  633. Xleaving only the previously computed constant numeric value.
  634. X.TP
  635. X.B =
  636. XEnter a numeric constant or expression into the current cell.
  637. X.I pname
  638. Xprompts for the expression on the top line.
  639. XThe usual way to enter a number into a cell is to type ``='',
  640. Xthen enter the number in response to the prompt on the top line.
  641. XThe quick numeric entry option, enabled through the
  642. X.B \-n
  643. Xoption or
  644. X.I ^T
  645. Xcommand, shows the prompt when you enter the first digit of a number
  646. X(you can skip typing ``='').
  647. X.\" ----------
  648. X.TP
  649. X.B <
  650. XEnter a label string into the current cell
  651. Xto be flushed left against the left edge of the cell.
  652. X.\" ----------
  653. X.IP \fB"\fP
  654. X.PD 0
  655. X.TP
  656. X.B >
  657. XEnter a label string into the current cell
  658. Xto be flushed right against the right edge of the cell.
  659. X.PD
  660. X.\" ----------
  661. X.PP
  662. XStrings you enter must start with ".
  663. XYou can leave off the trailing " and
  664. X.I pname
  665. Xwill add it for you.
  666. XYou can also enter a string expression
  667. Xby backspacing over the opening " in the prompt.
  668. X.\" ----------
  669. X.TP
  670. X.B e
  671. XEdit the value associated with the current cell.
  672. XThis is identical to ``=''
  673. Xexcept that the command line starts out containing
  674. Xthe old numeric value or expression associated with the cell.
  675. X.\" ----------
  676. X.TP
  677. X.B E
  678. XEdit the string associated with the current cell.
  679. XThis is identical to ``<'', ``"'', or ``>''
  680. Xexcept that the command line starts out containing
  681. Xthe old string value or expression associated with the cell.
  682. X.\" ----------
  683. X.PP
  684. XTo enter and edit a cell's number part, use the ``='' and
  685. X.I e
  686. Xcommands.
  687. XTo enter and edit a cell's string part, use the ``<'', ``"'', ``>'', and
  688. X.I E
  689. Xcommands.
  690. XSee the sections below on numeric and string expressions for more information.
  691. X.\" ----------
  692. X.TP
  693. X.B x
  694. XClear the current cell.
  695. XDeletes the numeric value, label string, and/or numeric or string expression.
  696. XYou can prefix this command with a count
  697. Xof the number of cells on the current row to clear.  The current column is
  698. Xused if column recalculation order is set.
  699. XCells cleared with this command may be recalled
  700. Xwith any of the
  701. X.I pull
  702. Xcommands (see below).
  703. X.\" ----------
  704. X.TP
  705. X.B m
  706. XMark a cell to be used as the source for the
  707. X.I copy
  708. Xcommand.
  709. X.\" ----------
  710. X.TP
  711. X.B c
  712. XCopy the last marked cell to the current cell,
  713. Xupdating row and column references in its numeric or string expression, if any.
  714. X.\" ----------
  715. X.TP
  716. X.B +
  717. XIf not in numeric mode, add the current numeric argument (default 1)
  718. Xto the value of the current cell.  In numeric mode, ``+'' introduces a new
  719. Xnumeric expression or value, the same as ``=''. 
  720. X.\" ----------
  721. X.TP
  722. X.B -
  723. XIf not in numeric mode, subtract the current numeric argument (default 1)
  724. Xfrom the value of the current cell.  In numeric mode, ``-'' introduces a new,
  725. Xnegative, numeric expression or value, like ``=''. 
  726. X.\" ==========
  727. X.SS "File Commands"
  728. X.\" ----------
  729. X\0 \" exactly one blank line (hard to get)
  730. X.PD 0
  731. X.TP
  732. X.B G
  733. XGet a new database from a file.
  734. XIf encryption is enabled,
  735. Xthe file is decrypted before it is loaded into the spreadsheet.
  736. X.PD
  737. X.\" ----------
  738. X.TP
  739. X.B P
  740. XPut the current database into a file.
  741. XIf encryption is enabled,
  742. Xthe file is encrypted before it is saved.
  743. X.\" ----------
  744. X.TP
  745. X.B W
  746. XWrite a listing of the current database into a file
  747. Xin a form that matches its appearance on the screen.
  748. XThis differs from the
  749. X.I Put
  750. Xcommand in that its files are intended to be reloaded with
  751. X.IR Get ,
  752. Xwhile
  753. X.I Write
  754. Xproduces a file for people to look at.  Hidden rows or columns
  755. Xare not shown when the data is printed.
  756. X.\" ----------
  757. X.TP
  758. X.B T
  759. XWrite a listing of the current database to a file,
  760. Xbut include delimiters suitable for processing by the
  761. X.IR tbl ,
  762. X.IR LaTeX ,
  763. Xor
  764. X.I TeX
  765. Xtable processors.
  766. XThe delimiters are controlled by the
  767. X.I tblstyle
  768. Xoption.  See
  769. X.I Set
  770. Xabove.
  771. XThe delimters are are a colon\ (:) for style
  772. X.IR 0 or tbl
  773. Xand an ampersand\ (&) for style
  774. X.IR latex or tex .
  775. X.\" ----------
  776. X.PP
  777. XWith the
  778. X.IR Put ,
  779. X.IR Write ,
  780. Xand
  781. X.I Table
  782. Xcommands, the optional range argument writes a subset of the spreadsheet to
  783. Xthe output file.
  784. X.\" ----------
  785. X.PP
  786. XWith the
  787. X.I Write
  788. Xand
  789. X.I Table
  790. Xcommands, if you try to write to the last file used with the
  791. X.I Get
  792. Xor
  793. X.I Put
  794. Xcommands, or the file specified on the command line when
  795. X.I pname
  796. Xwas invoked, you are asked to confirm
  797. Xthat the (potentially) dangerous operation is really what you want.
  798. X.\" ----------
  799. X.PP
  800. XThe three output commands,
  801. X.IR Put ,
  802. X.IR Write ,
  803. Xand
  804. X.IR Table ,
  805. Xcan pipe their (unencrypted only) output to a program.
  806. XTo use this feature,
  807. Xenter ``| program'' to the prompt asking for a filename.
  808. XFor example, to redirect the output of the
  809. X.I Write
  810. Xcommand to the printer,
  811. Xyou might enter ``| lpr -p''.
  812. X.\" ----------
  813. X.TP
  814. X.B M
  815. XMerge the database from the named file into the current database.
  816. XValues and expressions defined in the named file
  817. Xare read into the current spreadsheet
  818. Xoverwriting the existing entries at matching cell locations.
  819. X.\" ----------
  820. X.TP
  821. X.B R
  822. XRun macros.
  823. XSince
  824. X.I pname
  825. Xfiles are saved as ASCII files,
  826. Xit is possible to use them as primitive macro definition files.
  827. XThe
  828. X.I Run
  829. Xcommand makes this easier.
  830. XIt's like the
  831. X.I Merge
  832. Xcommand,
  833. Xbut prints a saved path name as the start of the filename to merge in.
  834. XThe string to use is set with the
  835. X.I Define
  836. Xcommand.
  837. XTo write macros, you must be familiar with the file format written by the
  838. X.I Put
  839. Xcommand.
  840. XThis facility is still primitive and could be much improved.
  841. X.\" ----------
  842. X.TP
  843. X.B D
  844. XDefine a path for the
  845. X.I Run
  846. Xcommand to use.
  847. X.\" ----------
  848. X.PP
  849. XAll file operations take a filename as the first argument
  850. Xto the prompt on the top line.
  851. XThe prompt supplies a " to aid in typing in the filename.
  852. XThe filename can also be obtained from a cell's label string
  853. Xor string expression.
  854. XIn this case, delete the leading " with the backspace key
  855. Xand enter a cell name such as
  856. X.I a22
  857. Xinstead.
  858. XIf the resulting string starts with ``|'',
  859. Xthe rest of the string is interpreted as a
  860. X.SM UNIX
  861. Xcommand, as above.
  862. X.\" ==========
  863. X.SS "Row and Column Commands"
  864. X.\" ----------
  865. XThese commands can be used on either rows or columns.
  866. XThe second letter of the command is either a row designator
  867. X(one of the characters
  868. X.IR r ,
  869. X.IR ^B ,
  870. X.IR ^F ,
  871. X.IR h ,
  872. X.IR l )
  873. Xor a column designator (one of
  874. X.IR c ,
  875. X.IR ^P ,
  876. X.IR ^N ,
  877. X.IR k ,
  878. X.IR j ).
  879. XA small menu lists the choices for the second letter
  880. Xwhen you type the first letter of one of these commands.
  881. XCommands which move or copy cells
  882. Xalso modify the row and column references in affected cell expressions.
  883. XThe references may be frozen by using the
  884. X.I fixed
  885. Xoperator or using the
  886. X.I $
  887. Xcharacter in the reference to the cell (see below).
  888. X.\" ----------
  889. X.TP
  890. X.B "ir, ic"
  891. XInsert a new row (column)
  892. Xby moving the row (column) containing the cell cursor,
  893. Xand all following rows (columns), down (right) one row (column).
  894. XThe new row (column) is empty.
  895. X.\" ----------
  896. X.TP
  897. X.B "ar, ac"
  898. XAppend a new row (column) immediately following the current row (column).
  899. XIt is initialized as a copy of the current one.
  900. X.\" ----------
  901. X.TP
  902. X.B "dr, dc"
  903. XDelete the current row (column).
  904. X.\" ----------
  905. X.TP
  906. X.B "pr, pc, pm"
  907. XPull deleted rows (columns) back into the spreadsheet.
  908. XThe last deleted set of cells is put back into the spreadsheet
  909. Xat the current location.
  910. X.I pr
  911. Xinserts enough rows to hold the data.
  912. X.I pc
  913. Xinserts enough columns to hold the data.
  914. X.I pm
  915. X(merge) does not insert rows or columns;
  916. Xit overwrites the cells beginning at the current cell cursor location.
  917. X.\" ----------
  918. X.TP
  919. X.B "vr, vc"
  920. XRemove expressions from the affected rows (columns),
  921. Xleaving only the values which were in the cells
  922. Xbefore the command was executed.
  923. X.\" ----------
  924. X.TP
  925. X.B "zr, zc"
  926. XHide (``zap'') the current row (column).
  927. XThis keeps a row (column) from being displayed but keeps it in the data base.
  928. XThe status of the rows and columns is saved with the data base so hidden
  929. Xrows and columns will be still
  930. Xbe hidden when you reload the spreadsheet.  Hidden rows or columns are not
  931. Xprinted by the
  932. X.I W
  933. Xcommand.
  934. X.\" ----------
  935. X.TP
  936. X.B "sr, sc"
  937. XShow hidden rows (columns).
  938. XEnter a range of rows (columns) to be revealed.
  939. XThe default is the first range of rows (columns) currently hidden.
  940. XThis command ignores the repeat count, if any.
  941. X.\" ----------
  942. X.TP
  943. X.B f
  944. XSet the output format to be used
  945. Xfor printing the numeric values in each cell in the current column.
  946. XEnter two numbers:
  947. Xthe total width in characters of the column,
  948. Xand the number of digits to follow decimal points.
  949. XValues are rounded off to the least significant digit displayed.
  950. XThe total column width affects displays of strings as well as numbers.
  951. XA preceding count can be used to affect more than one column.
  952. XThis command has only a column version (no second letter).
  953. X.\" ==========
  954. X.SS "Range Commands"
  955. X.\" ----------
  956. XRange operations affect a rectangular region on the screen
  957. Xdefined by the upper left and lower right cells in the region.
  958. XAll of the commands in this class start with a slash;
  959. Xthe second letter of the command indicates which command.
  960. XA small menu lists the choices for the second letter when you type ``/''.
  961. X.I pname
  962. Xprompts for needed parameters for each command.
  963. XPhrases surrounded by square brackets in the prompt are informational only
  964. Xand may be erased with the backspace key.
  965. X.\" ----------
  966. X.PP
  967. XPrompts requesting variable names may be satisfied
  968. Xwith either an explicit variable name, such as
  969. X.IR A10 ,
  970. Xor with a variable name previously defined in a
  971. X.I /d
  972. Xcommand (see below).
  973. XRange name prompts require either an explicit range such as
  974. X.IR A10:B20 ,
  975. Xor a range name previously defined with a
  976. X.I /d
  977. Xcommand.
  978. XA default range shown in the second line
  979. Xis used if you omit the range from the command or press the
  980. X.SM TAB
  981. Xkey (see below).
  982. XThe default range can be changed by moving the cell cursor
  983. Xvia the control commands
  984. X.RI ( ^P ,
  985. X.IR ^N ,
  986. X.IR ^B ,
  987. X.IR ^F )
  988. Xor the arrow keys.
  989. XThe cells in the default range are highlighted
  990. X(using the terminal's standout mode, if available).
  991. X.\" ----------
  992. X.TP
  993. X.B /x
  994. XClear a range.
  995. XCells cleared with this command may be recalled with any of the
  996. X.I pull
  997. Xcommands.
  998. X.\" ----------
  999. X.TP
  1000. X.B /v
  1001. XValues only.
  1002. XThis command removes the expressions from a range of cells,
  1003. Xleaving just the values of the expressions.
  1004. X.\" ----------
  1005. X.TP
  1006. X.B /c
  1007. XCopy a source range to a destination range.
  1008. XThe source and destination may be different sizes.
  1009. XThe result is always one or more full copies of the source.
  1010. XCopying a row to a row yields a row.
  1011. XCopying a column to a column yields a column.
  1012. XCopying a range to anything yields a range.
  1013. XCopying a row to a column or a column to a row yields a range
  1014. Xwith as many copies of the source as there are cells in the destination.
  1015. XThis command can be used to duplicate a cell through an arbitrary range
  1016. Xby making the source a single cell range such as
  1017. X.IR b20:b20 .
  1018. X.\" ----------
  1019. X.TP
  1020. X.B /f
  1021. XFill a range with constant values
  1022. Xstarting with a given value and increasing by a given increment.
  1023. XEach row is filled before moving on to the next row if row order
  1024. Xrecalculation is set.  Column order fills each column in the range
  1025. Xbefore moving on to the next column.
  1026. XThe start and increment numbers may be positive or negative.
  1027. XTo fill all cells with the same value, give an increment of zero.
  1028. X.\" ----------
  1029. X.TP
  1030. X.B /d
  1031. XUse this command to assign a symbolic name to a single cell
  1032. Xor a rectangular range of cells on the screen.
  1033. XThe parameters are the name, surrounded by "",
  1034. Xand either a single cell name such as
  1035. X.I A10
  1036. Xor a range such as
  1037. X.IR a1:b20 .
  1038. XNames defined in this fashion are used by the program in future prompts,
  1039. Xmay be entered in response to prompts requesting a cell or range name,
  1040. Xand are saved when the spreadsheet is saved with the
  1041. X.I Put
  1042. Xcommand.
  1043. XNames defined must be more than two alpha characters long
  1044. Xto differentiate them from a column names,
  1045. Xand must not have embedded special characters.
  1046. XNames may include the character ``_'' or numerals
  1047. Xas long as they occur after the first three alpha characters.
  1048. X.\" ----------
  1049. X.TP
  1050. X.B /s
  1051. XThis command lists (shows) the currently defined range names.
  1052. XIf there are no defined range names, then a message is given,
  1053. Xotherwise
  1054. Xit pipes output to
  1055. X.IR sort ,
  1056. Xthen to
  1057. X.IR less .
  1058. XIf the environment variable PAGER is set, its value is used in place of
  1059. X.IR less.
  1060. X.\" ----------
  1061. X.TP
  1062. X.B /u
  1063. XUse this command to undefine a previously defined range name.
  1064. X.\" ==========
  1065. X.SS "Miscellaneous Commands"
  1066. X.\" ----------
  1067. X\0 \" exactly one blank line (hard to get)
  1068. X.PD 0
  1069. X.TP
  1070. X.B Q
  1071. X.TP
  1072. X.B q
  1073. X.TP
  1074. X.B ^C
  1075. XExit from
  1076. X.IR pname .
  1077. XIf you made any changes since the last
  1078. X.I Get
  1079. Xor
  1080. X.IR Put ,
  1081. X.I pname
  1082. Xasks about saving your data before exiting.
  1083. X.PD
  1084. X.\" ----------
  1085. X.TP
  1086. X.B ^G
  1087. X.PD 0
  1088. X.TP
  1089. X.B ESC
  1090. XAbort entry of the current command.
  1091. X.PD
  1092. X.\" ----------
  1093. X.TP
  1094. X.B ?
  1095. XEnter an interactive help facility.  Lets you look up brief
  1096. Xsummaries of the main features of the program.  The help facility is
  1097. Xstructured like this manual page so it is easy to find more
  1098. Xinformation on a particular topic.
  1099. X.\" ----------
  1100. X.TP
  1101. X.B !
  1102. XShell escape.
  1103. X.I pname
  1104. Xprompts for a shell command to run.
  1105. XEnd the command line with the
  1106. X.SM RETURN
  1107. Xkey.
  1108. XIf the environment variable
  1109. X.SM SHELL
  1110. Xis defined, that shell is run.
  1111. XIf not, /bin/sh is used.
  1112. XGiving a null command line starts the shell in interactive mode.
  1113. XA second ``!'' repeats the previous command.
  1114. X.\" ----------
  1115. X.TP
  1116. X.B ^L
  1117. XRedraw the screen.
  1118. X.\" ----------
  1119. X.TP
  1120. X.B ^R
  1121. XRedraw the screen with special highlighting of cells to be filled in.
  1122. XThis is useful for finding values you need to provide or update
  1123. Xin a form with which you aren't familiar
  1124. Xor of which you have forgotten the details.
  1125. X
  1126. XIt's also useful for checking a form you are creating.
  1127. XAll cells which contain constant numeric values
  1128. X(not the result of a numeric expression)
  1129. Xare highlighted temporarily,
  1130. Xuntil the next screen change, however minor.
  1131. XTo avoid ambiguity,
  1132. Xthe current range (if any) and current cell are not highlighted.
  1133. X.\" ----------
  1134. X.TP
  1135. X.B ^X
  1136. XThis command is similar to
  1137. X.IR ^R ,
  1138. Xbut highlights cells which have expressions.
  1139. XIt also displays the expressions in the highlighted cells
  1140. Xas left-flushed strings,
  1141. Xinstead of the numeric values and/or label strings of those cells.
  1142. XThis command makes it easier to check expressions,
  1143. Xat least when they fit in their cells or the following cell(s) are blank
  1144. Xso the expressions can slop over (like label strings).
  1145. XIn the latter case, the slop over is not cleared on the next screen update,
  1146. Xso you may want to type
  1147. X.I ^L
  1148. Xafter the
  1149. X.I ^X
  1150. Xin order to clean up the screen.
  1151. X.\" ----------
  1152. X.TP
  1153. X.B @
  1154. XRecalculates the spreadsheet.
  1155. X.\" ----------
  1156. X.TP
  1157. X.B ^V
  1158. XType, in the command line, the name of the current cell
  1159. X(the one at the cell cursor).
  1160. XThis is useful when entering expressions
  1161. Xwhich refer to other cells in the table.
  1162. X.\" ----------
  1163. X.TP
  1164. X.B ^W
  1165. XType, in the command line, the expression attached to the current cell.
  1166. XIf there is none, the result is ``?''.
  1167. X.\" ----------
  1168. X.TP
  1169. X.B ^A
  1170. XType, in the command line, the numeric value of the current cell, if any.
  1171. X.\" ----------
  1172. X.PP
  1173. XThe
  1174. X.IR ^V ,
  1175. X.IR ^W ,
  1176. Xand
  1177. X.I ^A
  1178. Xcommands only work when the character cursor
  1179. Xis on the command line and beyond the first character.
  1180. X.\" ----------
  1181. X.TP
  1182. X.B TAB
  1183. XWhen the character cursor is on the top line,
  1184. Xdefines a range of cells via the cursor control commands or the arrow keys.
  1185. XThe range is highlighted,
  1186. Xstarts at the cell where you typed
  1187. X.SM TAB,
  1188. Xand continues through the current cell cursor.
  1189. XPressing
  1190. X.SM TAB
  1191. Xagain causes the highlighted range to be entered into the command line
  1192. Xand the highlighting to be turned off.
  1193. XThis is most useful for defining ranges to functions such as
  1194. X.IR @sum ().
  1195. XPressing ``)'' acts just like typing the
  1196. X.SM TAB
  1197. Xkey the second time and adds the closing ``)''.
  1198. XNote that when you give a range command,
  1199. Xyou don't need to press the first
  1200. X.SM TAB
  1201. Xto begin defining a range starting with the current cell.
  1202. X.\" ==========
  1203. X.SS "Variable Names"
  1204. X.\" ----------
  1205. XNormally, a variable name is just the name of a cell, such as
  1206. X.IR K20 .
  1207. XThe value is the numeric or string value of the cell,
  1208. Xaccording to context.
  1209. X.\" ----------
  1210. X.PP
  1211. XWhen a cell's expression (formula) is copied to another location via
  1212. X.I copy
  1213. Xor
  1214. X.IR range-copy ,
  1215. Xvariable references are by default offset by the amount the formula moved.
  1216. XThis allows the new formula to work on new data.
  1217. XIf cell references are not to change,
  1218. Xyou can either use the
  1219. X.I fixed
  1220. Xoperator (see below),
  1221. Xor one of the following variations on the cell name.
  1222. X.\" ----------
  1223. X.TP
  1224. X.I K20
  1225. XReferences cell
  1226. X.IR K20 ;
  1227. Xthe reference changes when the formula is copied.
  1228. X.\" ----------
  1229. X.TP
  1230. X.BI $ K $ 20
  1231. XAlways refers to cell
  1232. X.IR K20 ;
  1233. Xthe reference stays fixed when the formula is copied.
  1234. X.\" ----------
  1235. X.TP
  1236. X.BI $ K20
  1237. XKeeps the column fixed at column K;
  1238. Xthe row is free to vary.
  1239. X.\" ----------
  1240. X.TP
  1241. X.IB K $ 20
  1242. XSimilarly, this fixes the row and allows the column to vary.
  1243. X.\" ----------
  1244. X.PP
  1245. XThese conventions also hold on defined ranges.
  1246. XRange references vary when formulas containing them are copied.
  1247. XIf the range is defined with fixed variable references,
  1248. Xthe references do not change.
  1249. X.\" ----------
  1250. X.TP
  1251. X.B fixed
  1252. XTo make a variable not change automatically when a cell moves,
  1253. Xput the word
  1254. X.I fixed
  1255. Xin front of the reference, for example:
  1256. XB1 \(** fixed C3.
  1257. X.\" ==========
  1258. X.SS "Numeric Expressions"
  1259. X.\" ----------
  1260. XNumeric expressions used with the ``=''
  1261. Xand
  1262. X.I e
  1263. Xcommands have a fairly conventional syntax.
  1264. XTerms may be
  1265. Xconstants,
  1266. Xvariable names,
  1267. Xparenthesized expressions,
  1268. Xand negated terms.
  1269. XRanges may be operated upon with range functions such as sum
  1270. X.RI ( @sum ())
  1271. Xand average
  1272. X.RI ( @avg ()).
  1273. XTerms may be combined using binary operators.
  1274. X.\" ----------
  1275. X.TP
  1276. X.BR \- e
  1277. XNegation.
  1278. X.\" ----------
  1279. X.TP
  1280. X.RB e + e
  1281. XAddition.
  1282. X.\" ----------
  1283. X.TP
  1284. X.RB e \- e
  1285. XSubtraction.
  1286. X.\" ----------
  1287. X.TP
  1288. X.RB e \(** e
  1289. XMultiplication.
  1290. X.\" ----------
  1291. X.TP
  1292. X.RB e / e
  1293. XDivision.
  1294. X.\" ----------
  1295. X.TP
  1296. X.RB e1 % e2
  1297. Xe1 mod e2.
  1298. X.\" ----------
  1299. X.TP
  1300. X.RB e ^ e
  1301. XExponentiation.
  1302. X.\" ----------
  1303. X.TP
  1304. X.RB e < e
  1305. X.PD 0
  1306. X.TP
  1307. X.RB e <= e
  1308. X.TP
  1309. X.RB e = e
  1310. X.TP
  1311. X.RB e != e
  1312. X.TP
  1313. X.RB e >= e
  1314. X.TP
  1315. X.RB e > e
  1316. XRelationals:
  1317. Xtrue (1) if and only if the indicated relation holds,
  1318. Xelse false (0).
  1319. XNote that ``<='', ``!='', and ``>=''
  1320. Xare converted to their ``~()'' equivalents.
  1321. X.PD
  1322. X.\" ----------
  1323. X.TP
  1324. X.BR ~ e
  1325. XBoolean operator
  1326. X.SM NOT.
  1327. X.\" ----------
  1328. X.TP
  1329. X.RB e & e
  1330. XBoolean operator
  1331. X.SM AND.
  1332. X.\" ----------
  1333. X.TP
  1334. X.RB e | e
  1335. XBoolean operator
  1336. X.SM OR.
  1337. X.\" ----------
  1338. X.TP
  1339. X.RB @if (e, e, e)
  1340. X.PD 0
  1341. X.TP
  1342. X.RB e ? e : e
  1343. XConditional:
  1344. XIf the first expression is true then the value of the second is returned,
  1345. Xotherwise the value of the third.
  1346. X.\" ----------
  1347. X.PP
  1348. XOperator precedence from highest to lowest is:
  1349. X.PP
  1350. X.nf
  1351. X.RS
  1352. X\-, ~
  1353. X^
  1354. X\(**, /
  1355. X+, \-
  1356. X<, <=, =, !=, >=, >
  1357. X&
  1358. X|
  1359. X?:
  1360. X.RE
  1361. X.fi
  1362. X.\" ==========
  1363. X.SS "Built-in Range Functions"
  1364. X.\" ----------
  1365. XThese functions return numeric values.
  1366. X.\" ----------
  1367. X.TP 18
  1368. X.BR @sum (r)
  1369. XSum all valid (nonblank) entries in the region
  1370. Xwhose two corners are defined by the two variable names (e.g.
  1371. X.IR c5:e14 )
  1372. Xor the range name specified.
  1373. X.\" ----------
  1374. X.TP 18
  1375. X.BR @prod (r)
  1376. XMultiply together all valid (nonblank) entries in the specified region.
  1377. X.\" ----------
  1378. X.TP 18
  1379. X.BR @avg (r)
  1380. XAverage all valid (nonblank) entries in the specified region.
  1381. X.\" ----------
  1382. X.TP 18
  1383. X.BR @count (r)
  1384. XCount all valid (nonblank) entries in the specified region.
  1385. X.\" ----------
  1386. X.TP 18
  1387. X.BR @max (r)
  1388. XReturn the maximum value in the specified region.  See also the multi argument
  1389. Xversion of
  1390. X.I @max
  1391. Xbelow.
  1392. X.\" ----------
  1393. X.TP 18
  1394. X.BR @min (r)
  1395. XReturn the minimum value in the specified region.  See also the multi argument
  1396. Xversion of
  1397. X.I @min
  1398. Xbelow.
  1399. X.\" ----------
  1400. X.TP 18
  1401. X.BR @stddev (r)
  1402. XReturn the sample standard deviation of the cells in the specified region.
  1403. X.\" ----------
  1404. X.TP 18
  1405. X.BR @lookup (e,r)
  1406. X.PD 0
  1407. X.TP 18
  1408. X.BR @lookup (se,r)
  1409. X.PD
  1410. XEvaluates the expression then searches through the range
  1411. X.I r
  1412. Xfor a matching value.
  1413. XThe range should be either a single row or a single column.
  1414. XThe expression can be either a string
  1415. Xexpression or a numeric expression.  If it is a numeric expression,
  1416. Xthe range is searched for the the last value less than or equal to 
  1417. X.IR e .
  1418. XIf the expression is a string expression, the string portions
  1419. Xof the cells in the range are searched for an exact string match.
  1420. XThe value returned is the numeric value from the next row and the same
  1421. Xcolumn as the match, if the range was a single row, or the value from
  1422. Xthe next column and the same row as the match if the range was a single
  1423. Xcolumn.
  1424. X.\" ----------
  1425. X.TP 18
  1426. X.BR @hlookup (e,r,n)
  1427. X.PD 0
  1428. X.TP 18
  1429. X.BR @hlookup (se,r,n)
  1430. X.PD
  1431. XEvaluates the expression then searches through the first row in the range
  1432. X.I r
  1433. Xfor a matching value.
  1434. XThe expression can be either a string
  1435. Xexpression or a numeric expression.  If it is a numeric expression,
  1436. Xthe row is searched for the the last value less than or equal to 
  1437. X.IR e .
  1438. XIf the expression is a string expression, the string portions
  1439. Xof the cells in the row are searched for an exact string match.
  1440. XThe value returned is the numeric value from the same column
  1441. X.I n
  1442. Xrows below the match.
  1443. X.\" ----------
  1444. X.TP 18
  1445. X.BR @vlookup (e,r,n)
  1446. X.PD 0
  1447. X.TP 18
  1448. X.BR @vlookup (se,r,n)
  1449. X.PD
  1450. XEvaluates the expression then searches through the first column in the range
  1451. X.I r
  1452. Xfor a matching value.
  1453. XThe expression can be either a string
  1454. Xexpression or a numeric expression.  If it is a numeric expression,
  1455. Xthe column is searched for the the last value less than or equal to 
  1456. X.IR e .
  1457. XIf the expression is a string expression, the string portions
  1458. Xof the cells in the column are searched for an exact string match.
  1459. XThe value returned is the numeric value from the same row
  1460. X.I n
  1461. Xcolumns to the right of the match.
  1462. X.\" ----------
  1463. X.TP 18
  1464. X.BR @index (e,r)
  1465. XUse the value of the expression 
  1466. X.I e
  1467. Xto index into
  1468. Xthe range
  1469. X.IR r .
  1470. XThe numeric value at that position is returned. 
  1471. XThe value 1 selects the first item in the range,
  1472. X2 selects the second item, etc.
  1473. X.I R
  1474. Xshould be either a single row or a single
  1475. Xcolumn.
  1476. X.\" ----------
  1477. X.TP 18
  1478. X.BR @stindex (e,r)
  1479. XUse the value of 
  1480. X.I e
  1481. Xto index into
  1482. Xthe range
  1483. X.IR r .
  1484. XThe string value at that position is returned. 
  1485. XThe value 1 selects the first item in the range,
  1486. X2 selects the second item, etc.
  1487. XThe range should be either a single row or a single
  1488. Xcolumn.
  1489. X.\" ==========
  1490. X.SS "Built-in Numeric Functions"
  1491. X.\" ----------
  1492. XAll of these functions operate on floating point numbers (doubles)
  1493. Xand return numeric values.
  1494. XMost of them are standard system functions more fully described in
  1495. X.IR math (3).
  1496. XThe trig functions operate with angles in radians.
  1497. X.\" ----------
  1498. X.TP 18
  1499. X.BR @sqrt (e)
  1500. XReturn the square root of
  1501. X.IR e .
  1502. X.\" ----------
  1503. X.TP 18
  1504. X.BR @exp (e)
  1505. XReturn the exponential function of
  1506. X.IR e .
  1507. X.\" ----------
  1508. X.TP 18
  1509. X.BR @ln (e)
  1510. XReturn the natural logarithm of
  1511. X.IR e .
  1512. X.\" ----------
  1513. X.TP 18
  1514. X.BR @log (e)
  1515. XReturn the base 10 logarithm of
  1516. X.IR e .
  1517. X.\" ----------
  1518. X.TP 18
  1519. X.BR @floor (e)
  1520. XReturn the largest integer not greater than
  1521. X.IR e .
  1522. X.\" ----------
  1523. X.TP 18
  1524. X.BR @ceil (e)
  1525. XReturn the smallest integer not less than
  1526. X.IR e .
  1527. X.\" ----------
  1528. X.TP 18
  1529. X.BR @rnd (e)
  1530. XRound
  1531. X.I e
  1532. Xto the nearest integer.
  1533. X.TP 18
  1534. X.BR @round (e,n)
  1535. XRound
  1536. X.I e
  1537. Xto
  1538. X.I n
  1539. Xdecimal places.
  1540. X.\" ----------
  1541. X.TP 18
  1542. X.BR @abs (e)
  1543. X.PD 0
  1544. X.TP 18
  1545. X.BR @fabs (e)
  1546. XReturn the absolute value of
  1547. X.IR e .
  1548. X.\" ----------
  1549. X.TP 18
  1550. X.BR @pow (e1,e2)
  1551. XReturn
  1552. X.I e1
  1553. Xraised to the power of
  1554. X.IR e2 .
  1555. X.\" ----------
  1556. X.TP 18
  1557. X.BR @hypot (e1,e2)
  1558. XReturn sqrt(e1\(**e1+e2\(**e2), taking precautions against unwarranted
  1559. Xoverflows.
  1560. X.\" ----------
  1561. X.TP 18
  1562. X.B pi
  1563. XA constant quite close to pi.
  1564. X.\" ----------
  1565. X.TP 18
  1566. X.BR @dtr (e)
  1567. XConvert
  1568. X.I e
  1569. Xin degrees to radians.
  1570. X.\" ----------
  1571. X.TP 18
  1572. X.BR @rtd (e)
  1573. XConvert
  1574. X.I e
  1575. Xin radians to degrees.
  1576. X.\" ----------
  1577. X.TP 18
  1578. X.BR @sin (e)
  1579. X.PD 0
  1580. X.TP 18
  1581. X.BR @cos (e)
  1582. X.TP 18
  1583. X.BR @tan (e)
  1584. XReturn trigonometric functions of radian arguments.
  1585. XThe magnitude of the arguments are not checked to assure meaningful results.
  1586. X.PD
  1587. X.\" ----------
  1588. X.TP 18
  1589. X.BR @asin (e)
  1590. XReturn the arc sine of
  1591. X.I e
  1592. Xin the range -pi/2 to pi/2.
  1593. X.\" ----------
  1594. X.TP 18
  1595. X.BR @acos (e)
  1596. XReturn the arc cosine of
  1597. X.I e
  1598. Xin the range 0 to pi.
  1599. X.\" ----------
  1600. X.TP 18
  1601. X.BR @atan (e)
  1602. XReturn the arc tangent of
  1603. X.I e
  1604. Xin the range -pi/2 to pi/2.
  1605. X.\" ----------
  1606. X.TP 18
  1607. X.BR @atan2 (e1,e2)
  1608. XReturns the arc tangent of
  1609. X.IR e1 / e2
  1610. Xin the range -pi to pi.
  1611. X.\" ----------
  1612. X.TP 18
  1613. X.BR @max (e1,e2,...)
  1614. XReturn the maximum of the values of the expressions.  Two or more expressions
  1615. Xmay be specified.  See also the range version of 
  1616. X.I @max
  1617. Xabove.
  1618. X.\" ----------
  1619. X.TP 18
  1620. X.BR @min (e1,e2,...)
  1621. XReturn the minimum of the values of the expressions.  Two or more expressions
  1622. Xmay be specified.  See also the range version of 
  1623. X.I @min
  1624. Xabove.
  1625. X.\" ----------
  1626. X.TP 18
  1627. X.BR @ston (se)
  1628. XConvert string expression
  1629. X.I se
  1630. Xto a numeric value.
  1631. X.\" ----------
  1632. X.TP 18
  1633. X.BR @eqs (se1,se2)
  1634. XReturn 1 if string expression
  1635. X.I se1
  1636. Xhas the same value as string expression
  1637. X.IR se2 ,
  1638. X0 otherwise.
  1639. X.\" ----------
  1640. X.TP 18
  1641. X.BR @nval (se,e)
  1642. XReturn the numeric value of a cell selected by name.
  1643. XString expression
  1644. X.I se
  1645. Xmust evaluate to a column name (``A''-``AE'') and
  1646. X.I e
  1647. Xmust evaluate to a row number (0-199). 
  1648. XIf
  1649. X.I se
  1650. Xor
  1651. X.I e
  1652. Xis out of bounds, or the cell has no numeric value, the result is 0.
  1653. XYou can use this for simple table lookups.
  1654. XBe sure the table doesn't move unexpectedly!
  1655. XSee also
  1656. X.IR @sval ()
  1657. Xbelow.
  1658. X.\" ==========
  1659. X.SS "String Expressions"
  1660. X.\" ----------
  1661. XString expressions are made up of constant strings
  1662. X(characters surrounded by double quotation marks),
  1663. Xvariables
  1664. X(cell names, which refer to the cells's label strings or expressions),
  1665. Xand string functions.
  1666. XNote that string expressions are only allowed
  1667. Xwhen entering a cell's label string, not its numeric part.
  1668. XAlso note that string expression results may be left or right flushed,
  1669. Xaccording to the type of the cell's string label.
  1670. X.\" ----------
  1671. X.TP
  1672. X.B #
  1673. XConcatenate strings.
  1674. XFor example, the string expression
  1675. X.IP ""
  1676. X    A0 # "zy dog"
  1677. X.IP ""
  1678. Xdisplays the string ``the lazy dog'' in the cell if the value of
  1679. X.IR A0 's
  1680. Xstring is ``the la''.
  1681. X.\" ==========
  1682. X.SS "Built-in String Functions"
  1683. X.\" ----------
  1684. X\0 \" exactly one blank line (hard to get)
  1685. X.PD 0
  1686. X.TP 18
  1687. X.BR @substr (se,e1,e2)
  1688. XExtract and return from string expression
  1689. X.I se
  1690. Xthe substring indexed by character number
  1691. X.I e1
  1692. Xthrough character number
  1693. X.I e2
  1694. X(defaults to the size of
  1695. X.I se
  1696. Xif beyond the end of it).
  1697. XIf
  1698. X.I e1
  1699. Xis less than 1 or greater than
  1700. X.IR e2 ,
  1701. Xthe result is the null string.
  1702. XFor example,
  1703. X.PD
  1704. X.IP ""
  1705. X    @substr ("Nice jacket", 4, 7)
  1706. X.IP ""
  1707. Xreturns the string ``e jac''.
  1708. X.\" ----------
  1709. X.TP 18
  1710. X.BR @fmt (se,e)
  1711. XConvert a number to a string.
  1712. XThe argument
  1713. X.I se
  1714. Xmust be a valid
  1715. X.IR printf (3)
  1716. Xformat string.
  1717. X.I e
  1718. Xis converted according to the standard rules.
  1719. XFor example, the expression
  1720. X.IP ""
  1721. X    @fmt ("\(**\(**%6.3f\(**\(**", 10.5)
  1722. X.IP ""
  1723. Xyields the string ``\(**\(**10.500\(**\(**''.
  1724. X.I e
  1725. Xis a double, so applicable formats are e, E, f, g, and G.
  1726. XTry ``%g'' as a starting point.
  1727. X.\" ----------
  1728. X.TP 18
  1729. X.BR @sval (se,e)
  1730. XReturn the string value of a cell selected by name.
  1731. XString expression
  1732. X.I se
  1733. Xmust evaluate to a column name (``A''-``AE'') and
  1734. X.I e
  1735. Xmust evaluate to a row number (0-199). 
  1736. XIf
  1737. X.I se
  1738. Xor
  1739. X.I e
  1740. Xis out of bounds, or the cell has no string value,
  1741. Xthe result is the null string.
  1742. XYou can use this for simple table lookups.
  1743. XBe sure the table doesn't move unexpectedly!
  1744. X.\" ----------
  1745. X.TP 18
  1746. X.BR @ext (se,e)
  1747. XCall an external function (program or script).
  1748. XThe purpose is to allow arbitrary functions on values,
  1749. Xe.g. table lookups and interpolations.
  1750. XString expression
  1751. X.I se
  1752. Xis a command or command line to call with
  1753. X.IR popen (3).
  1754. XThe value of
  1755. X.I e
  1756. Xis converted to a string and appended to the command line as an argument.
  1757. XThe result of
  1758. X.IR @ext ()
  1759. Xis a string:
  1760. Xthe first line printed to standard output by the command.
  1761. XThe command should emit exactly one output line.
  1762. XAdditional output, or output to standard error, messes up the screen.
  1763. X.IR @ext ()
  1764. Xreturns a null string and prints an appropriate warning
  1765. Xif external functions are disabled,
  1766. X.I se
  1767. Xis null, or the attempt to run the command fails.
  1768. X.IP ""
  1769. XExternal functions can be slow to run,
  1770. Xand if enabled are called at each screen update,
  1771. Xso they are disabled by default.
  1772. XYou can enable them with
  1773. X.I ^T
  1774. Xwhen you really want them called.
  1775. X.IP ""
  1776. XA simple example:
  1777. X.IP ""
  1778. X    @ext ("echo", a1)
  1779. X.IP ""
  1780. XYou can use
  1781. X.IR @ston ()
  1782. Xto convert the
  1783. X.IR @ext ()
  1784. Xresult back to a number.
  1785. XFor example:
  1786. X.IP ""
  1787. X    @ston (@ext ("form.sc.ext", a9 + b9))
  1788. X.IP ""
  1789. XNote that you can built a command line (including more argument values)
  1790. Xfrom a string expression with concatenation.
  1791. XYou can also "hide" the second argument by ending the command line
  1792. X(first argument) with `` #'' (shell comment).
  1793. X.\" ==========
  1794. X.SS "Built-in Financial Functions"
  1795. X.\" ----------
  1796. XFinancial functions compute the mortgage (or loan) payment, future value,
  1797. Xand the present value functions.  Each accepts
  1798. Xthree arguments, an amount, a rate of interest (per period), and 
  1799. Xthe number of periods.
  1800. XThese functions are the same as those commonly found in other spreadsheets
  1801. Xand financial calculators
  1802. X.\" ----------
  1803. X.TP 18
  1804. X.BR @pmt (e1,e2,e3)
  1805. X.IR @pmt (60000,.01,360)
  1806. Xcomputes the monthly payments for a $60000 mortgage at 12% annual interest
  1807. X(.01 per month) for 30 years (360 months).
  1808. X.\" ----------
  1809. X.TP 18
  1810. X.BR @fv (e1,e2,e3)
  1811. X.IR @fv (100,.005,36)
  1812. Xcomputes the future value for of 36 monthly payments of $100 at 6% 
  1813. Xinterest (.005 per month).  It answers the question: "How much
  1814. Xwill I have in 36 months if I deposit $100 per month in a savings
  1815. Xaccount paying 6% interest compounded monthly?"
  1816. X.\" ----------
  1817. X.TP 18
  1818. X.BR @pv (e1,e2,e3)
  1819. X.IR @pv (1000,.015,36)
  1820. Xcomputes the present value of an a ordinary annuity of
  1821. X36 monthly payments of $1000 at 18% annual interest.
  1822. XIt answers the question: "How much can I borrow at 18% for 30 years
  1823. Xif I pay $1000 per month?"
  1824. X.\" ==========
  1825. X.SS "Built-in Date and Time Functions"
  1826. X.\" ----------
  1827. XTime for
  1828. X.I pname
  1829. Xfollows the system standard:
  1830. Xthe number of seconds since 1970.
  1831. XAll date and time functions except
  1832. X.IR @date ()
  1833. Xreturn numbers, not strings.
  1834. X.\" ----------
  1835. X.TP 18
  1836. X.B @now
  1837. XReturn the current time encoded
  1838. Xas the number of seconds since the beginning of the
  1839. Xepoch (December 31, 1969, midnight, GMT.)
  1840. X.\" ----------
  1841. X.TP 18
  1842. X.BR @dts (e1,e2,e3)
  1843. X.IR @dts (9,14,1988)
  1844. Xconverts the date September 14, 1988
  1845. Xto the number of seconds from the epoch
  1846. Xto the first second of 9/14/88, local time.
  1847. XFor example,
  1848. X.IR @date ( @dts (12,14,1976))
  1849. Xyields
  1850. X.IP ""
  1851. X.I "    Tue Dec 14 00:00:00 1976"
  1852. X.IP ""
  1853. XThe month should be range from  1 to 12, the day should range from
  1854. X1 to the number of days in the specified month, and the year should
  1855. Xrange from 1970 to 1999.
  1856. X.\" ----------
  1857. X.TP 18
  1858. X.BR @tts (e1,e2,e3)
  1859. X.IR @tts (8,20,45)
  1860. Xconverts the time 8:40:45 to the number of seconds since
  1861. Xmidnight, the night before.  The hour should range from 0 to 23;
  1862. Xthe minutes and seconds should range from 0 to 59.
  1863. X.\" ----------
  1864. X.PP
  1865. XThe following functions take the time in seconds
  1866. X(e.g. from
  1867. X.IR @now )
  1868. Xas an argument and return the specified value.
  1869. XThe functions all convert from GMT to local time.
  1870. X.\" ----------
  1871. X.TP 18
  1872. X.BR @date (e)
  1873. XConvert the time in seconds to a date string
  1874. X24 characters long in the following form:
  1875. X.IP ""
  1876. X.I "    Sun Sep 16 01:03:52 1973"
  1877. X.IP ""
  1878. XNote that you can extract parts of this fixed-format string with
  1879. X.IR @substr ().
  1880. X.\" ----------
  1881. X.TP 18
  1882. X.BR @year (e)
  1883. XReturn the year.
  1884. XValid years begin with 1970.
  1885. XThe last legal year is system dependent.
  1886. X.\" ----------
  1887. X.TP 18
  1888. X.BR @month (e)
  1889. XReturn the month, encoded as 1 (January) to 12 (December).
  1890. X.\" ----------
  1891. X.TP 18
  1892. X.BR @day (e)
  1893. XReturn the day of the month, encoded as 1 to 31.
  1894. X.\" ----------
  1895. X.TP 18
  1896. X.BR @hour (e)
  1897. XReturn the number of hours since midnight, encoded as 0 to 23.
  1898. X.\" ----------
  1899. X.TP 18
  1900. X.BR @minute (e)
  1901. XReturn the number of minutes since the last full hour, encoded as 0 to 59.
  1902. X.\" ----------
  1903. X.TP 18
  1904. X.BR @second (e)
  1905. XReturn the number of seconds since the last full minute, encoded as 0 to 59.
  1906. X.\" ==========
  1907. X.SS "Spreadsheet Update"
  1908. X.\" ----------
  1909. XRe-evaluation of spreadsheet expressions
  1910. Xis done by row or by column depending on the selected calculation order.
  1911. XEvaluation is repeated up to 
  1912. X.I iterations
  1913. Xtimes for each update if necessary,
  1914. Xso forward references usually work as expected.  See
  1915. X.I set
  1916. Xabove.
  1917. XIf stability is not reached after ten iterations,
  1918. Xa warning is printed.
  1919. XThis is usually due to a long series of forward references,
  1920. Xor to unstable cyclic references (for example, set
  1921. X.IR A0 's
  1922. Xexpression to ``A0+1'').
  1923. X.\" ==========
  1924. X.SH SEE ALSO
  1925. Xbc(1), dc(1), crypt(1), ppname(1)
  1926. X.\" ==========
  1927. X.SH BUGS
  1928. XTop-to-bottom, left-to-right evaluation of expressions is silly.
  1929. XA proper following of the dependency graph
  1930. Xwith (perhaps) recourse to relaxation should be implemented.
  1931. X.\" ----------
  1932. X.PP
  1933. XEditing is crude.
  1934. XAll you can do is backspace over and retype text to be altered.
  1935. XThere is no easy way to switch a leftstring to a rightstring or vice versa.
  1936. XOf course, you can always write the spreadsheet to a file with
  1937. X.IR Put ,
  1938. Xedit it by calling an editor on the file with ``!'',
  1939. Xand read it back with
  1940. X.I Get
  1941. X-- if you are comfortable editing spreadsheet files.
  1942. X.\" ----------
  1943. X.PP
  1944. XOnly one previous value is saved from any call of
  1945. X.IR @ext ().
  1946. XIf it is used more than once in a spreadsheet
  1947. Xand external functions are enabled and later disabled,
  1948. Xthe last returned value pops up in several places.
  1949. X.\" ----------
  1950. X.PP
  1951. XOn some systems,
  1952. Xif the cell cursor is in column 0 with topline enabled
  1953. X(so the current cell is highlighted),
  1954. Xor if any cell in column 0 is highlighted,
  1955. Xthe corresponding row number gets displayed and then blanked
  1956. Xduring a screen refresh.
  1957. XThis looks like a bug in
  1958. X.IR curses .
  1959. X.\" ----------
  1960. X.PP
  1961. XMany commands give no indication (a message or beep) if they have null effect.
  1962. XSome should give confirmation of their action, but they don't.
  1963. END_OF_FILE
  1964.   if test 45229 -ne `wc -c <'sc.doc'`; then
  1965.     echo shar: \"'sc.doc'\" unpacked with wrong size!
  1966.   fi
  1967.   # end of 'sc.doc'
  1968. fi
  1969. echo shar: End of archive 1 \(of 6\).
  1970. cp /dev/null ark1isdone
  1971. MISSING=""
  1972. for I in 1 2 3 4 5 6 ; do
  1973.     if test ! -f ark${I}isdone ; then
  1974.     MISSING="${MISSING} ${I}"
  1975.     fi
  1976. done
  1977. if test "${MISSING}" = "" ; then
  1978.     echo You have unpacked all 6 archives.
  1979.     rm -f ark[1-9]isdone
  1980. else
  1981.     echo You still must unpack the following archives:
  1982.     echo "        " ${MISSING}
  1983. fi
  1984. exit 0
  1985. exit 0 # Just in case...
  1986.